home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Informant Complete 1995 - 2000
/
Delphi Informant Complete 1995 to 2000.iso
/
Delphi Informant Magazine Complete Works SOURCE CODE 1995.rar
/
1995
/
DEC
/
DI9512BV
/
unit1.pas
< prev
Wrap
Pascal/Delphi Source File
|
1995-10-26
|
3KB
|
126 lines
unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Grids, Outline, StdCtrls, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Outline1: TOutline;
Image1: TImage;
Label1: TLabel;
BitBtn1: TBitBtn;
Label2: TLabel;
procedure Outline1Click(Sender: TObject);
procedure Outline1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
bmpMalePyr,
bmpFemalePyr: TBitMap;
{$R *.DFM}
procedure TForm1.Outline1Click(Sender: TObject);
begin
Form1.Caption :='Outline Index ' + inttostr(Outline1.SelectedItem) + '. ' +
Outline1.Items[Outline1.SelectedItem].FullPath
end;
procedure TForm1.Outline1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
Var
s: String;
x, y: Integer;
ItemIndex: LongInt;
Node: ToutlineNode;
Offset: Integer;
begin
ItemIndex := Outline1.GetItem(Rect.Left, Rect.Top);
Node := Outline1.Items[ItemIndex];
with Outline1.Canvas do
Begin
if State = [odSelected, odFocused] then
Begin
Brush.Color := clHighlight;
Pen.Color := clHighlightText;
end
else
Begin
Brush.Color := Outline1.Color;
Pen.Color := clWindowText;
end;
FillRect(Rect);
Rect.Left := Rect.Left + (Node.Level * 15);
{ First draw the Icon }
if Copy(Node.Text,length(Node.Text),1) = 'F' then
BrushCopy(Bounds(Rect.Left,Rect.Top,35,25),
bmpFemalePyr,
Bounds(0, 0, 35, 25),
clLtGray)
else
BrushCopy(Bounds(Rect.Left,Rect.Top,35,25),
bmpMalePyr,
Bounds(0, 0, 35, 25),
clLtGray);
{ Set the font }
Font := Outline1.Font;
{ Then draw the string }
s := copy(Node.Text, 1, Length(Node.Text) - 2);
{ Indent and center Text }
x := Rect.left + bmpMalePyr.Width + 7;
y := Rect.Top + (((Rect.Bottom - Rect.Top) - abs(Font.Height)) div 2);
TextOut(x, y, s);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{ Load the bitmap from the current directory }
bmpMalePyr := TBitMap.Create;
bmpMalePyr.LoadFromFile('MalePyr.Bmp');
bmpFemalePyr := TBitMap.Create;
bmpFemalePyr.LoadFromFile('FemPyr.Bmp');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
bmpMalePyr.Free;
bmpFemalePyr.Free;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Form1.Close;
end;
end.